package md.mru.core.domains.administration;

import md.mru.core.domains.orders.FolderOrder;
import md.mru.core.domains.type.EventType;
import md.mru.core.domains.type.TreeChangesType;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

/**
 * @author sergiu.marin
 * @since 01/06/2014.
 */
@Entity
@Table(name = "events", schema = "c##mru_optimized")
public class Event implements Serializable {

    private static final long serialVersionUID = 8610074066816918880L;

    @Id
    @Column(name = "id", unique = true, nullable = false, precision = 10, scale = 0)
    @GeneratedValue(generator = "events_sequence")
    @SequenceGenerator(name = "events_sequence", sequenceName = "events_sequence", allocationSize = 1)
    private long id;

    @ManyToOne
    @JoinColumn(name = "order_id")
    private FolderOrder order;

    @Column(name = "created_date")
    private Date createdDate = new Date();

    @ManyToOne
    @JoinColumn(name = "created_by_user_id")
    private User createdByUser;

    @Enumerated(EnumType.STRING)
    @Column(name = "event_type")
    private EventType eventType;

    @Column(name = "node_path")
    private String nodePath;

    @Enumerated(EnumType.STRING)
    @Column(name = "tree_changes_type")
    private TreeChangesType treeChangesType;

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public FolderOrder getOrder() {
        return order;
    }

    public void setOrder(FolderOrder order) {
        this.order = order;
    }

    public Date getCreatedDate() {
        return createdDate;
    }

    public void setCreatedDate(Date createdDate) {
        this.createdDate = createdDate;
    }

    public User getCreatedByUser() {
        return createdByUser;
    }

    public void setCreatedByUser(User createdByUser) {
        this.createdByUser = createdByUser;
    }

    public EventType getEventType() {
        return eventType;
    }

    public void setEventType(EventType eventType) {
        this.eventType = eventType;
    }

    public String getNodePath() {
        return nodePath;
    }

    public void setNodePath(String nodePath) {
        this.nodePath = nodePath;
    }

    public TreeChangesType getTreeChangesType() {
        return treeChangesType;
    }

    public void setTreeChangesType(TreeChangesType treeChangesType) {
        this.treeChangesType = treeChangesType;
    }
}
